/**
 * 
 * @param {String} key  cookie的名称 
 * @param {String} value    cookie的值
 * @param {Number} expires  传递过期时间，单位为秒  默认值0表示关闭浏览器失效
 */
function setCookie(key, value, expires) {
    if (expires == 0) {
        document.cookie = `${key}=${value};path=/`;
    } else {
        let d = new Date();
        d.setTime(d.getTime() - 8 * 3600 * 1000 + expires * 1000);
        document.cookie = `${key}=${value};path=/;expires=${d}`;
    }
}
/**
 * 删除cookie
 * @param {String} key  cookie 的名称 
 */
function removeCookie(key) {
    setCookie(key, '', -1);
}


function getCookie(key) {
    let value = '';
    document.cookie.split(';').forEach(item => {
        let keyValue = item.split('=')
        if (ley == keyValue[0]) {
            value = keyValue[1];
        }
    })
    return value;
}   
